#
# ShoeBox
#  A start product for Plone - ShoeBox
#
# ShoeBox.py
#  The Product
#
# Author: Christian Koller <admin@iecw.net>
#
# Released under GNU GPL v2 or later
#

from Products.Archetypes.public import *
from Products.ShoeBox.config import PROJECTNAME
from Products.CMFCore import CMFCorePermissions
from Products.validation import V_REQUIRED
from AccessControl import ClassSecurityInfo

from Products.ShoeBox.config import PROJECTNAME

class ShoeBox(BaseFolder):
    """ Shoe Box container """
    meta_type = 'ShoeBox'
    
    security  = ClassSecurityInfo()
    
    allowed_content_types = (
        'ShoeBoxEntry',
        'ShoeBoxAccount',
        )
    ##
    ##  The Schema includes two variables, on for the Repository itself and one for a Path within the Repository
    ##
    
    ## Set the icon for the ShoeBox
    content_icon = 'shoebox.png'
    
    ##
    ##  Redefine the view tab (action) for ShoeBox
    ##
    actions = (
            {
                    'id': 'view',
                    'name': 'View',
                    'action': 'string:${folder_url}/shoebox_view',
                    'permissions': (CMFCorePermissions.View,),
                    'category':'object',
            },
    )
    aliases = {
            '(Default)'  : 'view',
            'view'       : '',
            'index.html' : '',
            'edit'       : 'base_edit',
            'properties' : 'base_metadata',
            'sharing'    : 'folder_localrole_form',
            'gethtml'    : '',
            'mkdir'      : '',
            }

    def getAccounts(self):
        """
        Returns a list of accounts available to this entry
        """
        accounts = self.getFolderContents(batch=False,
           contentFilter={'portal_type' : 'ShoeBoxAccount'}, full_objects=True)

        return accounts

## Register the new type within Zope
registerType(ShoeBox,PROJECTNAME)
